package cn.java86.myschool.service;

import cn.java86.myschool.dao.SubjectDao;
import cn.java86.myschool.entity.Page;
import cn.java86.myschool.entity.Subject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author oldliu
 * @since 1.0
 */
@Service
public class SubjectService implements SubjectServiceI {
    @Autowired//@Qualifier
    private SubjectDao subjectDao;

    @Override
    public int add(Subject s) {
        //???
        return subjectDao.add(s);
    }

    @Override
    public int update(Subject s) {
        return subjectDao.update(s);
    }

    @Override
    public int del(Long id) {
        return subjectDao.del(id);
    }

    @Override
    public Subject get(Long id) {
        return subjectDao.get(id);
    }
    //分页搜索
    @Override
    public Page<Subject> search(int pageNo, int pageSize, String name) {
        List<Subject> list = this.subjectDao.search(pageNo, pageSize, name);
        long total = this.subjectDao.findTotal(name);
        return new Page<>(list, pageNo, total, pageSize);
    }
}
